//=== EmualtorCodeGenerator.h - Class definition for the EmualtorJIT -*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file defines the interface between the emulator interpreter and jit.
//
//===----------------------------------------------------------------------===//

#include "EmulatorInterpreter.h"
#include <cassert>  // for assert.
#include <stdio.h>

void EmulatorInterpreter::initializeFieldOffset(void)
{
  prev_rip_offset         = ((uint32_t(*)(char*))find_field_offset_by_name)("prev_rip");
  async_event_offset      = ((uint32_t(*)(char*))find_field_offset_by_name)("async_event");
  address_to_xlate_offset = ((uint32_t(*)(char*))find_field_offset_by_name)("address_to_xlate");
  address_xlated_offset   = ((uint32_t(*)(char*))find_field_offset_by_name)("address_xlated");
}

uint32_t EmulatorInterpreter::get_reg_offset(uint8_t index, uint8_t type)
{
  return ((uint32_t(*)(uint8_t, uint8_t))find_reg_offset_by_index)(index, type);
}
